package com.action.popLayer;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.entity.other.City;
import com.entity.other.Province;
import com.entity.other.University;
import com.service.profile.ProfileService;
import com.util.abstractAction.AbstractAction;

public class PopLayerAction extends AbstractAction {
	
	private static final long serialVersionUID = -4512150586622750132L;

	@Autowired
	private ProfileService profileService;
	
	private List<Province> provinceList;
	
	private List<City> cityList;
	
	private int provinceId;
	
	private int cityId;
	
	private List<University> universityList;

	public String toChooseSchoolPopLayer(){
		try {
			provinceList=profileService.getAllProvince();
			universityList=profileService.getUniversityByProvinceId(provinceList.get(0).getId());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "toChooseSchoolPopLayer";
	}
	
	public void getUniversityByProvince(){
		try {
			universityList=profileService.getUniversityByProvinceId(provinceId);
			String jsonStr="";
			for (University university : universityList) {
				jsonStr+="<a href=\"#\" class=\"university\" universityId=\""+university.getId()+"\" universityName=\""+university.getUniversityName()+"\" provinceId=\""+university.getProvinceId()+"\">"+university.getUniversityName()+" </a>";
			}
			print(jsonStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public List<Province> getProvinceList() {
		return provinceList;
	}

	public void setProvinceList(List<Province> provinceList) {
		this.provinceList = provinceList;
	}

	public List<City> getCityList() {
		return cityList;
	}

	public void setCityList(List<City> cityList) {
		this.cityList = cityList;
	}

	public int getProvinceId() {
		return provinceId;
	}

	public void setProvinceId(int provinceId) {
		this.provinceId = provinceId;
	}

	public int getCityId() {
		return cityId;
	}

	public void setCityId(int cityId) {
		this.cityId = cityId;
	}

	public List<University> getUniversityList() {
		return universityList;
	}

	public void setUniversityList(List<University> universityList) {
		this.universityList = universityList;
	}

	
}
